package com.ruoyi.system.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.QImPj;
import com.ruoyi.system.service.IQImPjService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * IM评价Controller
 * 
 * @author ruoyi
 * @date 2024-06-20
 */
@Controller
@RequestMapping("/system/pj")
public class QImPjController extends BaseController
{
    private String prefix = "system/pj";

    @Autowired
    private IQImPjService qImPjService;

   // @RequiresPermissions("system:pj:view")
   @CrossOrigin
    @GetMapping()
    public String pj()
    {
        return prefix + "/pj";
    }

    /**
     * 查询IM评价列表
     */
   // @RequiresPermissions("system:pj:list")
    @PostMapping("/list")
    @ResponseBody
    @CrossOrigin
    public TableDataInfo list(QImPj qImPj)
    {
        startPage();
        List<QImPj> list = qImPjService.selectQImPjList(qImPj);
        return getDataTable(list);
    }

    /**
     * 导出IM评价列表
     */
   // @RequiresPermissions("system:pj:export")
    @Log(title = "IM评价", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @CrossOrigin
    @ResponseBody
    public AjaxResult export(QImPj qImPj)
    {
        List<QImPj> list = qImPjService.selectQImPjList(qImPj);
        ExcelUtil<QImPj> util = new ExcelUtil<QImPj>(QImPj.class);
        return util.exportExcel(list, "IM评价数据");
    }

    /**
     * 新增IM评价
     */
   // @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存IM评价
     */
  //  @RequiresPermissions("system:pj:add")
    @CrossOrigin
    @Log(title = "IM评价", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(@RequestBody QImPj qImPj)
    {
        return toAjax(qImPjService.insertQImPj(qImPj));
    }

    /**
     * 修改IM评价
     */
    @CrossOrigin
   // @RequiresPermissions("system:pj:edit")
    @GetMapping("/edit/{imPingjiaId}")
    public String edit(@PathVariable("imPingjiaId") Long imPingjiaId, ModelMap mmap)
    {
        QImPj qImPj = qImPjService.selectQImPjByImPingjiaId(imPingjiaId);
        mmap.put("qImPj", qImPj);
        return prefix + "/edit";
    }

    /**
     * 修改保存IM评价
     */
  //  @RequiresPermissions("system:pj:edit")
    @CrossOrigin
    @Log(title = "IM评价", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(QImPj qImPj)
    {
        return toAjax(qImPjService.updateQImPj(qImPj));
    }

    /**
     * 删除IM评价
     */
    @CrossOrigin
    @RequiresPermissions("system:pj:remove")
    @Log(title = "IM评价", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(qImPjService.deleteQImPjByImPingjiaIds(ids));
    }
}
